package org.jeecg.modules.bigdatashow.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.bigdatashow.entity.Line;
import org.jeecg.modules.bigdatashow.mapper.LineMapper;
import org.jeecg.modules.bigdatashow.mapper.StationMapper;
import org.jeecg.modules.bigdatashow.service.ILineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 生产线
 * @Author: jeecg-boot
 * @Date:   2022-04-05
 * @Version: V1.0
 */
@Service
public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements ILineService {

    @Autowired
    LineMapper lineMapper;
    @Autowired
    StationMapper stationMapper;

    @Override
    public List<Line> list() {
        //查询所有产线
        List<Line> lineList = lineMapper.List();

        for (Line lines : lineList) {
            lines.setWorkstation(stationMapper.count(lines.getId()));
        }
        return lineList;
    }

    @Override
    public List<Line> getById(String id) {

        Line line = lineMapper.getById(id);
        Line line1 = line.setWorkstation(stationMapper.count(id));

        ArrayList<Line> lines = new ArrayList<>();
        lines.add(line1);

        return lines;
    }
}
